﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net;
using System.Text;
using System.Windows.Forms;

namespace ServerLib.Entities
{
    public partial class TakeNetworkForm : Form
    {
        private readonly List<IPAddress> _list;
        private readonly GetNetworkDelegate _d;

        public TakeNetworkForm(List<IPAddress> list, GetNetworkDelegate del)
        {
            InitializeComponent();
            Text = Server.Rm.GetString("Take") + ' ' + Server.Rm.GetString("Network").ToLower();
            button1.Text = Server.Rm.GetString("Ok");
            button2.Text = Server.Rm.GetString("Cancel");
            label1.Text = Server.Rm.GetString("TrapsPortListening");
            _d = del;
            _list = list;

            ipBox.DataSource = _list;
        }

        public override sealed string Text
        {
            get { return base.Text; }
            set { base.Text = value; }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.OK;
            _d(_list[ipBox.SelectedIndex]);
            Close();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.Abort;
            Close();
        }
    }
}
